<?php
$con = mysql_connect('localhost:3306','root');
if (!$con)
{
	die('Could not connect: ' . mysql_error());
}
else
{
	mysql_select_db('catan', $con);
	$sql = "select * from players where username = '". $_POST['username']. "'";
	$result = mysql_query($sql,$con);
	$row = mysql_fetch_array($result);
	if($row!=null)
	{
		echo "Sorry, this username already exists! <br />";
		echo "Please create another!";
		echo "<meta http-equiv='refresh' content='3; url=http://localhost/inscription.php'>";
	}
	else
	{
		$sql = "insert into players (username,level,password) values ('". $_POST['username']."',0,'". $_POST['password']."')";
		$result = mysql_query($sql,$con);  
	}
}
?>